import 'menu.dart';
import 'user.dart';

class UserProfileModel {
  User? user;
  List<String>? roles;
  List<String>? permissions;
  List<Menu>? menus;

  UserProfileModel({this.user, this.roles, this.permissions, this.menus});

  factory UserProfileModel.fromJson(Map<String, dynamic> json) {
    return UserProfileModel(
      user: json['user'] == null
          ? null
          : User.fromJson(json['user'] as Map<String, dynamic>),
      roles: json['roles'] as List<String>?,
      permissions: json['permissions'] as List<String>?,
      menus: (json['menus'] as List<dynamic>?)
          ?.map((e) => Menu.fromJson(e as Map<String, dynamic>))
          .toList(),
    );
  }

  Map<String, dynamic> toJson() => {
        'user': user?.toJson(),
        'roles': roles,
        'permissions': permissions,
        'menus': menus?.map((e) => e.toJson()).toList(),
      };
}
